package com.pengpeng.jjwt.common.exception;

import com.pengpeng.jjwt.common.result.ResultCode;

import java.text.MessageFormat;

/**
 * @author pengp
 * @date 2022年03月03日 16:16
 */
public class CustomException extends RuntimeException{
    ResultCode resultCode;

    public CustomException(ResultCode resultCode){
        super(resultCode.message());
        this.resultCode = resultCode;
    }

    public CustomException(ResultCode resultCode,Object... args){
        super(resultCode.message());
        String message = MessageFormat.format(resultCode.message(),args);
        resultCode.setMessage(message);
        this.resultCode = resultCode;
    }

    public ResultCode getResultCode(){
        return resultCode;
    }
}
